<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box {
        width: 800px;
        height: 800px;
        border: 1px solid red;
      }
    </style>
  </head>
  <body>
    <div id="box"></div>

    <script src="../js/three.js"></script>
    <script type="module">
      import {
        createBaseObj,
        addHelpLine,
        testAnimation,
        createViewController,
        createEasyBox,
      } from '../js/myThree.js'

      const oWrap = document.getElementById('box')
      const { scene, camera, renderer } = createBaseObj(oWrap)
      addHelpLine(scene, 1000)

      const mesh = createEasyBox(new THREE.Vector3(0, 0, 0), 10, 'orange')
      scene.add(mesh)

      const mesh2 = createEasyBox(new THREE.Vector3(15, 0, 0), 10, 'red')
      scene.add(mesh2)

      const geometry_light = new THREE.BoxGeometry(10, 10, 10)
      const material_light = new THREE.MeshPhongMaterial({
        color: 'green',
        // opacity: 1,
        // transparent: false,
        specular: 0x4488ee,
        shininess: 12
      })
      const mesh3 = new THREE.Mesh(geometry_light, material_light)
      mesh3.position.set(0, 20, 0)
      scene.add(mesh3)

      /**
       * 光源设置
       * */
      const point_light = new THREE.PointLight(0xffffff)
      point_light.position.set(10, 20, 0)

      scene.add(point_light)

      const amibient = new THREE.AmbientLight(0xff4444, 1)
      scene.add(amibient)
      const addNum = 0.01

      function doSth() {
        mesh.rotateY(0.01)
        mesh2.rotateX(0.01)
      }

      createViewController(renderer.domElement, camera)

      const animation = testAnimation({ scene, camera, renderer }, doSth)
      animation()
    </script>
  </body>
</html>
